package com.bit.BlogTest.Controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.bit.BlogTest.Model.Blog;
import com.bit.BlogTest.Service.BlogService;


@Controller
@RequestMapping("/add")
public class BlogAddController {
	
	@Autowired
	BlogService blogService;
	
	@RequestMapping
	public String action(@RequestParam String title, @RequestParam String content, @RequestParam String writer){
		if(title != "" && content != "" && writer != ""){
			Blog blog = new Blog(title, content, writer);
			blogService.insertContent(blog);
		}
		
		return "redirect:/blog";
	}
}
